#include <iostream>
#include <pthread.h>
namespace MutexMoudle
{
    class Mutex
    {
    public:
        Mutex()
        {
            pthread_mutex_init(&_key, nullptr);
        }
        void lock()
        {
            int n = pthread_mutex_lock(&_key);
            (void)n;
        }
        void unlock()
        {
            int n = pthread_mutex_unlock(&_key);
            (void)n;
        }
        pthread_mutex_t *Get()
        {
            return &_key;
        }
        ~Mutex()
        {
            pthread_mutex_destroy(&_key);
        }

    private:
        pthread_mutex_t _key;
    };
    class Mutexground
    {
    public:
        Mutexground(Mutex &mutex)
            : _mutex(mutex)
        {
            _mutex.lock();
        }
        ~Mutexground()
        {
            _mutex.unlock();
        }

    private:
        Mutex &_mutex;
    };
}